<template>
  <div class="mainos">
    <div class="main_spac1 paddingBottom5">
      <div class="main_white padding10 paddingBottom20">
        <div class="main_crumbs boxdq">
          <div class="main_crumbs_l">
            <a href="javascript:;" @click="$router.back(-1)">
              <i class="el-icon-arrow-down"></i>返回
            </a>
            <em>|</em>
            <span>查看订单</span>
          </div>
        </div>
        <div class="main_tile boxdq marginTop10">
          <div class="main_tile_l marginLeft0"><em></em>基础信息</div>
        </div>
        <div class="info">
           <div class="part">
              <div><span>客户：</span>{{ order_info.company_name }}</div>
              <div><span>订单号：</span>{{ order_info.order_sn }}</div>
              <div><span>订单金额：</span>{{ order_info.order_money }}</div>
              <div><span>订单状态：</span>{{ orderStatusList[order_info.order_status]}}</div>
           </div>
           <div class="part">
              <div><span>下单日期：</span>{{order_info.created_at? parseTime(order_info.created_at, "{y}-{m}-{d}"): ""}}</div>
              <div><span>收货人：</span> {{ order_info.receiving_name}}</div>
              <div><span>收货手机：</span> {{ order_info.receiving_mobile}}</div>
              <div><span>收货地址：</span>{{order_info.receiving_address}}</div>
           </div>
        <div class="remark"><span>订单备注：</span>{{order_info.remark}}</div>
        </div>
        <div class="main_tile boxdq marginTop10">
          <div class="main_tile_l marginLeft0"><em></em>商品信息</div>
          <div class="mainos_tile_r">合计：{{ total }}元</div>
        </div>
        <div class="main_table marginTop0">
          <el-table
            ref="multipleTable"
            v-loading="listLoading"
            :data="goods_info"
            element-loading-text="加载中"
            fit
            highlight-current-row
          >
          <el-table-column label="序号" prop="userId">
            <template slot-scope="scope">{{ scope.$index + 1 }}</template>
          </el-table-column>
          <el-table-column label="设备图片" >
            <template slot-scope="scope">
              <img :src="avatar.img_prefix+scope.row.pic" @click="showImg(avatar.img_prefix+scope.row.pic)" style="width:80px;height:80px;">
              <el-dialog :visible.sync="dialogVisible">
                  <img :src="showImgSrc"/>
              </el-dialog>
            </template>
          </el-table-column>
          <el-table-column label="设备名称"  prop="dev_name" class-name="main_hei" />
          <el-table-column label="规格/型号" prop="model" class-name="main_hei" />
          <el-table-column label="数量"   prop="num" class-name="main_hei" />
          <el-table-column label="售价" prop="goods_money" class-name="main_hei" />
          <el-table-column label="小计" prop="all_money" class-name="main_hei" />
          </el-table>
        </div>
        <div class="main_tile boxdq marginTop10">
          <div class="main_tile_l marginLeft0"><em></em>物流信息</div>
        </div>
        <div style="padding:10px;">
          <el-timeline :reverse="true">
            <el-timeline-item
              v-for="(item, index) in logistics"
              :key="index"
              :color="index==logistics.length-1?'#0bbd87':''"
              :timestamp="item.AcceptTime">
              {{item.AcceptStation}}
            </el-timeline-item>
          </el-timeline>
        </div>
        <div class="main_tile boxdq marginTop20">
          <div class="main_tile_l marginLeft0"><em></em>生命周期</div>
        </div>
        <div class="main_table marginTop0">
          <el-table
            ref="multipleTable"
            v-loading="listLoading"
            :data="logs"
            element-loading-text="加载中"
            fit
            highlight-current-row
          >
            <el-table-column
              label="管理员"
              prop="admin_name"
              class-name="main_hei"
            />
            <el-table-column
              label="操作"
              prop="operate.name"
              class-name="main_hei"
            />
            <el-table-column label="内容" prop="content" class-name="main_hei">
              <!-- <template slot-scope="scope">
                <div
                  v-for="(content, index) in scope.row.content"
                  :key="index"
                  class="marginTop5 marginBottom5"
                >
                  {{ content }}
                </div>
              </template> -->
            </el-table-column>
            <el-table-column label="IP" prop="ip" class-name="main_hei" />
            <el-table-column
              label="时间"
              prop="created_at"
              class-name="main_hei"
            >
              <template slot-scope="scope">{{
                parseTime(scope.row.created_at)
              }}</template>
            </el-table-column>
          </el-table>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import {devOrderDetail,devOrderLife,devOrderLogisticsInfo} from "@/api/brokerage/devorder";
import { parseTime } from "@/utils/index";
import { mapGetters } from "vuex";

export default {
  computed: {
    ...mapGetters(["avatar"]),
    total() {
      let sz = 0;
      this.goods_info.forEach((e) => {
        sz += Number(e.all_money);
      });
      return sz.toFixed(2);
    },
  },

  data() {
    return {
      // 时间
      parseTime,
      // 基本信息
      order_info:{},
      goods_info:[],  //商品信息
      logistics:[], //物流信息
      logs:[],  //生命周期
      listLoading: false,
      id: this.$route.query.id,
      orderStatusList: {
        0:'待付款',
        1:'待发货',
        2:'待收货',
        3:'已完成',
        4:'已取消',
      }, //状态列表
      showImgSrc:'',  //当前弹窗显示的图片
      filelist: [],
      dialogImageUrl: "",
      dialogVisible: false,
    };
  },
  created() {
    // 基本信息
    this.getData();
  },
  methods: {
    // 基本信息
    getData() {
      let data ={ id: this.id }
      devOrderDetail(data).then((res) => {
        if (res.errcode == 0) {
           this.order_info = res.data.order_info;
           this.goods_info = res.data.goods_info;
        } else {
          this.$message.error(res.errmsg);
        }
      });
      //生命周期
      devOrderLife(data).then((res) => {
        if (res.errcode == 0) {
          this.logs = res.data.list;
        } else {
          this.$message.error(res.errmsg);
        }
      });
      //物流信息
      devOrderLogisticsInfo(data).then((res) => {
        if (res.errcode == 0) {
          this.logistics = res.data.Traces;
        } else {
          // this.$message.error(res.errmsg);
        }
      });
    },
    // 图片-查看
    showImg(src) {
      this.showImgSrc = src;
      this.dialogVisible = true;
    },
  },
};
</script>
<style lang="scss" scoped>
@import "@/styles/variables.scss";

/deep/.main_table .el-table--small td .cell{
  height:auto;
}
.mainos {
  .main_tile {
    .mainos_tile_r {
      color: $colour_red;
      font-size: $font_14;
    }
  }
  .mainor_ex {
    position: fixed;
    width: 220px;
    height: 100%;
    background: $white;
    box-shadow: 0 6px 10px rgba(0, 21, 41, 0.08);
    top: 0;
    right: 0;
    z-index: 9999;
    transition: all 0.5s;
    transform: translate3d(100%, 0, 0);
    &.on {
      transform: translate3d(0, 0, 0);
    }
    .mainor_exb {
      position: absolute;
      width: 100%;
      height: calc(100% - 60px);
      overflow-y: auto;
      h3 {
        font-size: $font_16;
        color: $colour_18;
        height: 50px;
        line-height: 50px;
        border-bottom: 1px solid $colour_e6;
        padding-left: 20px;
      }
      .mainor_exb_an {
        padding-left: 20px;
        margin-top: 15px;
        /deep/.el-checkbox {
          display: block;
          margin-top: 15px;
          margin-bottom: 15px;
        }
      }
    }
    .mainor_exb_b {
      position: absolute;
      bottom: 0;
      width: 100%;
      border-top: 1px solid $colour_e6;
      height: 55px;
      text-align: center;
      /deep/.el-button--default {
        margin-top: 12px;
        border-color: $subActive;
        color: $menuText;
        &:hover {
          border-color: $menuActiveText;
          color: $menuActiveText;
        }
      }
    }
  }
}
.info{
   overflow: hidden;
   padding-left:20px;
   .part{
      width:50%;
      float: left;
      >div{
         margin-bottom:10px;
         >span{
           color:#999;
         }
      }
   }
   .remark{
     >span{
       color:#999;
     }
   }
}
.info2{
   padding-left:20px;
   .row{
      margin-bottom:10px;
      span{
        color:#999;
      }
   }
}
</style>
